/*
* Poppy Game Engine - https://pgetemplate.googlecode.com/svn/
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2008 Poppy
*/

#pragma once

#include "SystemDefines.h"
#include "SystemExportSymbol.h"
#include "CMemObject.h"

namespace PGESystem
{

	typedef enum
	{
		PSP_CTRL_SELECT     = 0x000001,
		PSP_CTRL_START      = 0x000008,

		PSP_CTRL_UP         = 0x000010,
		PSP_CTRL_RIGHT      = 0x000020,
		PSP_CTRL_DOWN      	= 0x000040,
		PSP_CTRL_LEFT      	= 0x000080,

		PSP_CTRL_LTRIGGER   = 0x000100,
		PSP_CTRL_RTRIGGER   = 0x000200,

		PSP_CTRL_TRIANGLE   = 0x001000,
		PSP_CTRL_CIRCLE     = 0x002000,
		PSP_CTRL_CROSS      = 0x004000,
		PSP_CTRL_SQUARE     = 0x008000,

		PSP_CTRL_HOME       = 0x010000,
		PSP_CTRL_HOLD       = 0x020000,
		PSP_CTRL_NOTE       = 0x800000,
		PSP_CTRL_SCREEN     = 0x400000,
		PSP_CTRL_VOLUP      = 0x100000,
		PSP_CTRL_VOLDOWN    = 0x200000,
		PSP_CTRL_WLAN_UP    = 0x040000,
		PSP_CTRL_REMOTE     = 0x080000,	
		PSP_CTRL_DISC       = 0x1000000,
		PSP_CTRL_MS         = 0x2000000,
	} PSP_CTRL_BUTTONS;

	typedef struct
	{
		DWORD 	m_dTimeStamp;
		DWORD 	m_dButtons;
		BYTE 	m_dLx;
		BYTE 	m_dLy;
		BYTE 	Rsrv[6];
	} CTRL_DATA, *LPCTRL_DATA;

	typedef enum
	{   
		USE_ANALOG_ROCKER = 0x1,
		USE_PEEK_MODE = 0x02,
		USE_BUFFER_MODE = 0x04
	} DIRECT_CTRL_FLAG;

	#ifdef WIN32
	#endif

	class PGESYSTEM_API CDirectCtrl : virtual public CMemObject
	{

	public:

		inline CDirectCtrl( BYTE flag );

		inline virtual ~CDirectCtrl();

		bool InitCtrl();

		void DestoryCtrl();

		inline void SetBufferCount( int count );

		inline void SetSamplingCycle( int cycle );

		void UpdateCtrlState();

		inline const LPCTRL_DATA GetStateBuffer();

	protected:

		CTRL_DATA	m_sData;
		BYTE		m_dFlag;
		int			m_dCount;
		int			m_dCycle;
		bool		m_bIsinited;

		#ifdef WIN32
		#endif

	};

	#include "CDirectCtrl.inl"

}
